package com.linapex.action;

import java.util.List;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Actions;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;

import com.linapex.manager.UserManager;
import com.linapex.models.User;
import com.yhm.pagination.PageUtil;

@ParentPackage("convention-default")
@Namespace(value="/")
@Scope("prototype")
public class UserAction {
	
	private PageUtil pageUtil;
	private User user;
	private List<User> users;
	private UserManager userManager=new UserManager();
	private Logger logger=Logger.getLogger(getClass());
	/**查询学生信息*/
	@Actions({
		@Action(value="findAll01",results={@Result(name="success",location="/page/pageList1.jsp")}),
		@Action(value="findAll02",results={@Result(name="success",location="/page/pageList2.jsp")}),
		@Action(value="findAll03",results={@Result(name="success",location="/page/pageList3.jsp")}),
		@Action(value="findAll04",results={@Result(name="success",location="/page/pageList4.jsp")}),
		@Action(value="findAll11",results={@Result(name="success",location="/page/pageList11.jsp")}),
		@Action(value="findAll12",results={@Result(name="success",location="/page/pageList12.jsp")}),
		@Action(value="findAll13",results={@Result(name="success",location="/page/pageList13.jsp")}),
		@Action(value="findAll14",results={@Result(name="success",location="/page/pageList14.jsp")})
	})
	public String findAll(){
		try {
			if(pageUtil==null) pageUtil=new PageUtil();
			logger.debug(pageUtil);
			pageUtil.setPageSize(4);
			if(user!=null) {
				logger.debug(user); //传递的用户信息:
			}
			users=userManager.findAll(user,pageUtil); //只需要包含当前页数,可能会传入每页记录数
			logger.debug(pageUtil);
		} catch (Exception e) {
			logger.debug("异常:"+e);
			e.printStackTrace();
		}
		return "success";
	}
	
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public List<User> getUsers() {
		return users;
	}
	public void setUsers(List<User> users) {
		this.users = users;
	}
	public PageUtil getPageUtil() {
		return pageUtil;
	}
	public void setPageUtil(PageUtil pageUtil) {
		this.pageUtil = pageUtil;
	}	
}
